package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.PremisesImageService;
import com.yixun.qfbao.apidto.PremisesTypeCountResDto;
import com.yixun.qfbao.apidto.SelectPremisesImageListResDto;
import com.yixun.qfbao.apidto.base.CommonReqDTO;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.util.exception.TServerException;
import com.yixun.qfbao.vo.GeneralReqVo;
import com.yixun.qfbao.vo.SetMainPushPremisesReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("selectPremisesImageListHander")
public class SelectPremisesImageListHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(SelectPremisesImageListHander.class);
    @Autowired
    private PremisesImageService premisesImageService;

    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        SetMainPushPremisesReqVo reqVo = (SetMainPushPremisesReqVo) reqDto;
        BaseResponseDTO<SelectPremisesImageListResDto> res = new BaseResponseDTO<>();
        SelectPremisesImageListResDto resDto = new SelectPremisesImageListResDto();
        try {
            resDto = premisesImageService.selectPremisesImageList(reqVo.getParams().getPremisesId());
        } catch (TServerException t) {
            logger.error("selectPremisesImageListHander tserverexception: {}", t);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg(t.getErrorMsg());
        } catch (Exception e) {
            logger.error("selectPremisesImageListHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("根据楼盘ID获取图片！");
        }
        res.setResult(resDto.getResult());
        res.setResData(resDto);
        return res;
    }
}
